 $(function(){
	//编辑器
    function checkTest(){
         var $commit = $('.facilities').val();
         console.log($commit);
         if($commit !=''){
             alert(123)
             return true
         }
         else {
             return false
         }
     }
 	var ue = UE.getEditor('editor');
 	//删除轮播图片
 	$('.deletePhoto').click(function(){
 		var obj = $(this);
        layer.confirm('确定要删除此图片吗？', {btn: ['是', '否']}, function(index){
            layer.load();
            var pId = obj.attr('did');
            var bpId = $('#bp_id').val();
            var url = obj.attr('durl');
            $.post(url, {bid: bpId, pid: pId}, function(result){
                layer.closeAll();
                if(result.status != 10000) {
                    layer.alert(result.message, {icon: 5});
                } else {
                    $('#img_' + pId).remove();
                    $('#a_' + pId).remove();
                }
            }, 'json');
        }, function(index){
            layer.close(index);
        });
 	});
 	//增加轮播图片
 	$('#btn_add_photo').click(function(){
 		var box = $('#bp_photos_box');
        box.append('<div class="input-group paddingTB5"><input type="file" class="form-control" name="bp_photos[]"><div class="input-group-addon bg_red cursor_pointer" onclick="$.bpPhotoDel(this)"><i class="fa fa-times"></i></div></div>');
 	});
 	$.extend({
        'bpPhotoDel': function(obj) {
            $(obj).parent().remove();
        }
    });
 	//添加设备设施
 	$('.add_equipment').click(function(){
        var $text = $('#add_equipmentText').val();
        var html ="";
        html+= '<div class="input-group">' +
            '<input type="text" class="form-control del_equipmentText" name="facilities[]" readonly value="'+$text+'">' +
            '<div class="input-group-addon bg_337ab7 cursor_pointer del_equipment"><i class="fa fa-trash-o"></i> 删除</div>' +
            '</div>';
        var $delText = $('.del_equipmentText').length;

        if($text) {
            if( $delText > 2) {
                layer.msg('最多只能添加三个',{icon: 2});
            } else if($('.del_equipmentText').last().val() == $text) {
                layer.msg('不能重复添加',{icon: 2});
            }
            else {
                $('#delBox').append(html);
                $('#add_equipmentText').val('');
            }
        }
        $('.del_equipment').click(function(){
             $(this).parent().remove();
        })
    });
 	//删除设备设施
 	$('.delfacilities').click(function(){
 		$(this).parent().prev().remove();
 		$(this).remove();
 	});

 })